//package cc.magicjson.example.demo.support;
//
//import cc.magicjson.example.demo.threadlocal.context.UserContext;
//import cc.magicjson.example.demo.web.respository.UserRepository;
//import jakarta.servlet.http.HttpServletRequest;
//import jakarta.servlet.http.HttpServletResponse;
//import org.springframework.stereotype.Component;
//import org.springframework.web.method.HandlerMethod;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import static java.util.Objects.nonNull;
//
///**
// * {@link HandlerInterceptor}
// *
// * @author <a href="mailto:it_magicjson@163.com">MagicJson</a>
// * @since 1.0.0
// */
//@Component
//public class UserHandlerInterceptor implements HandlerInterceptor {
//
//	@Override
//	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//		if (handler instanceof HandlerMethod) {
//			String token = request.getHeader("User-Account");
//			if (nonNull(token)) {
//				UserContext.setUserInfo(new UserRepository().getUserInfo(token));
//			}
//		}
//		return HandlerInterceptor.super.preHandle(request, response, handler);
//	}
//
//	@Override
//	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
//		UserContext.clearUserInfo();
//		HandlerInterceptor.super.afterCompletion(request, response, handler, ex);
//	}
//}
